import React, { Component } from 'react'

export default class Counter extends Component {

  constructor() {
    super();
    this.state = {
      num: 100
    }
  }

  // state={
  //   num:100
  // }

  handleClick(num) {
    //第一种
    // this.setState({
    //   num: this.state.num += 1
    // })
    // console.log(this.state.num)

    //第二种
    // this.setState({
    //   num: this.state.num += 1
    // },()=>{
    //   console.log(this.state.num)
    // })

    //第三种
    this.state.num += num;
    this.setState({})
  }

  handleClick1=(num,event)=>{
    this.state.num += num;
    this.setState({})
    console.log(event)
  }

  render() {
    return (
      <div>
        {this.state.num}
        <button onClick={() => this.handleClick(10)}>change</button>
        <button onClick={this.handleClick1.bind(this,10)}>change1</button>
      </div>
    )
  }
}
